home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JPopupMenu.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  14.8 KB  |  757 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Frame;
  6. import java.awt.Graphics;
  7. import java.awt.GraphicsConfiguration;
  8. import java.awt.GraphicsDevice;
  9. import java.awt.GraphicsEnvironment;
  10. import java.awt.Insets;
  11. import java.awt.Point;
  12. import java.awt.Rectangle;
  13. import java.awt.Toolkit;
  14. import java.awt.event.FocusEvent;
  15. import java.awt.event.KeyEvent;
  16. import java.awt.event.MouseEvent;
  17. import java.beans.PropertyChangeListener;
  18. import java.io.IOException;
  19. import java.io.ObjectInputStream;
  20. import java.io.ObjectOutputStream;
  21. import java.io.Serializable;
  22. import java.security.AccessController;
  23. import java.util.Vector;
  24. import javax.accessibility.Accessible;
  25. import javax.accessibility.AccessibleContext;
  26. import javax.swing.event.MenuKeyEvent;
  27. import javax.swing.event.MenuKeyListener;
  28. import javax.swing.event.PopupMenuEvent;
  29. import javax.swing.event.PopupMenuListener;
  30. import javax.swing.plaf.PopupMenuUI;
  31. import sun.security.action.GetPropertyAction;
  32.  
  33. public class JPopupMenu extends JComponent implements Accessible, MenuElement {
  34.    private static final String uiClassID = "PopupMenuUI";
  35.    private static final Object defaultLWPopupEnabledKey = new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey");
  36.    static boolean popupPostionFixDisabled = false;
  37.    transient Component invoker;
  38.    transient Popup popup;
  39.    transient Frame frame;
  40.    private int desiredLocationX;
  41.    private int desiredLocationY;
  42.    private String label;
  43.    private boolean paintBorder;
  44.    private Insets margin;
  45.    private boolean lightWeightPopup;
  46.    private SingleSelectionModel selectionModel;
  47.    private static final Object classLock;
  48.    private static final boolean TRACE = false;
  49.    private static final boolean VERBOSE = false;
  50.    private static final boolean DEBUG = false;
  51.  
  52.    public static void setDefaultLightWeightPopupEnabled(boolean var0) {
  53.       SwingUtilities.appContextPut(defaultLWPopupEnabledKey, var0);
  54.    }
  55.  
  56.    public static boolean getDefaultLightWeightPopupEnabled() {
  57.       Boolean var0 = (Boolean)SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
  58.       if (var0 == null) {
  59.          SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
  60.          return true;
  61.       } else {
  62.          return var0;
  63.       }
  64.    }
  65.  
  66.    public JPopupMenu() {
  67.       this((String)null);
  68.    }
  69.  
  70.    public JPopupMenu(String var1) {
  71.       this.label = null;
  72.       this.paintBorder = true;
  73.       this.margin = null;
  74.       this.lightWeightPopup = true;
  75.       this.label = var1;
  76.       this.lightWeightPopup = getDefaultLightWeightPopupEnabled();
  77.       this.setSelectionModel(new DefaultSingleSelectionModel());
  78.       this.enableEvents(16L);
  79.       this.setFocusTraversalKeysEnabled(false);
  80.       this.updateUI();
  81.    }
  82.  
  83.    public PopupMenuUI getUI() {
  84.       return (PopupMenuUI)this.ui;
  85.    }
  86.  
  87.    public void setUI(PopupMenuUI var1) {
  88.       super.setUI(var1);
  89.    }
  90.  
  91.    public void updateUI() {
  92.       this.setUI((PopupMenuUI)UIManager.getUI(this));
  93.    }
  94.  
  95.    public String getUIClassID() {
  96.       return "PopupMenuUI";
  97.    }
  98.  
  99.    protected void processFocusEvent(FocusEvent var1) {
  100.       super.processFocusEvent(var1);
  101.    }
  102.  
  103.    protected void processKeyEvent(KeyEvent var1) {
  104.       MenuSelectionManager.defaultManager().processKeyEvent(var1);
  105.       if (!var1.isConsumed()) {
  106.          super.processKeyEvent(var1);
  107.       }
  108.    }
  109.  
  110.    public SingleSelectionModel getSelectionModel() {
  111.       return this.selectionModel;
  112.    }
  113.  
  114.    public void setSelectionModel(SingleSelectionModel var1) {
  115.       this.selectionModel = var1;
  116.    }
  117.  
  118.    public JMenuItem add(JMenuItem var1) {
  119.       super.add(var1);
  120.       return var1;
  121.    }
  122.  
  123.    public JMenuItem add(String var1) {
  124.       return this.add(new JMenuItem(var1));
  125.    }
  126.  
  127.    public JMenuItem add(Action var1) {
  128.       JMenuItem var2 = this.createActionComponent(var1);
  129.       var2.setAction(var1);
  130.       this.add(var2);
  131.       return var2;
  132.    }
  133.  
  134.    Point adjustPopupLocationToFitScreen(int var1, int var2) {
  135.       Point var3 = new Point(var1, var2);
  136.       if (!popupPostionFixDisabled && !GraphicsEnvironment.isHeadless()) {
  137.          Toolkit var4 = Toolkit.getDefaultToolkit();
  138.          GraphicsConfiguration var7 = null;
  139.          GraphicsEnvironment var8 = GraphicsEnvironment.getLocalGraphicsEnvironment();
  140.          GraphicsDevice[] var9 = var8.getScreenDevices();
  141.  
  142.          for(int var10 = 0; var10 < var9.length; ++var10) {
  143.             if (var9[var10].getType() == 0) {
  144.                GraphicsConfiguration var11 = var9[var10].getDefaultConfiguration();
  145.                if (var11.getBounds().contains(var3)) {
  146.                   var7 = var11;
  147.                   break;
  148.                }
  149.             }
  150.          }
  151.  
  152.          if (var7 == null && this.getInvoker() != null) {
  153.             var7 = this.getInvoker().getGraphicsConfiguration();
  154.          }
  155.  
  156.          Rectangle var5;
  157.          Insets var6;
  158.          if (var7 != null) {
  159.             var6 = var4.getScreenInsets(var7);
  160.             var5 = var7.getBounds();
  161.          } else {
  162.             var6 = new Insets(0, 0, 0, 0);
  163.             var5 = new Rectangle(var4.getScreenSize());
  164.          }
  165.  
  166.          int var17 = var5.width - Math.abs(var6.left + var6.right);
  167.          int var18 = var5.height - Math.abs(var6.top + var6.bottom);
  168.          Dimension var12 = this.getPreferredSize();
  169.          long var13 = (long)var3.x + (long)var12.width;
  170.          long var15 = (long)var3.y + (long)var12.height;
  171.          if (var13 > (long)(var5.x + var17)) {
  172.             var3.x = var5.x + var17 - var12.width;
  173.          }
  174.  
  175.          if (var15 > (long)(var5.y + var18)) {
  176.             var3.y = var5.y + var18 - var12.height;
  177.          }
  178.  
  179.          if (var3.x < var5.x) {
  180.             var3.x = var5.x;
  181.          }
  182.  
  183.          if (var3.y < var5.y) {
  184.             var3.y = var5.y;
  185.          }
  186.  
  187.          return var3;
  188.       } else {
  189.          return var3;
  190.       }
  191.    }
  192.  
  193.    protected JMenuItem createActionComponent(Action var1) {
  194.       1 var2 = new 1(this);
  195.       ((JMenuItem)var2).setHorizontalTextPosition(11);
  196.       ((JMenuItem)var2).setVerticalTextPosition(0);
  197.       return var2;
  198.    }
  199.  
  200.    protected PropertyChangeListener createActionChangeListener(JMenuItem var1) {
  201.       return var1.createActionPropertyChangeListener0(var1.getAction());
  202.    }
  203.  
  204.    public void remove(int var1) {
  205.       if (var1 < 0) {
  206.          throw new IllegalArgumentException("index less than zero.");
  207.       } else if (var1 > this.getComponentCount() - 1) {
  208.          throw new IllegalArgumentException("index greater than the number of items.");
  209.       } else {
  210.          super.remove(var1);
  211.       }
  212.    }
  213.  
  214.    public void setLightWeightPopupEnabled(boolean var1) {
  215.       this.lightWeightPopup = var1;
  216.    }
  217.  
  218.    public boolean isLightWeightPopupEnabled() {
  219.       return this.lightWeightPopup;
  220.    }
  221.  
  222.    public String getLabel() {
  223.       return this.label;
  224.    }
  225.  
  226.    public void setLabel(String var1) {
  227.       String var2 = this.label;
  228.       this.label = var1;
  229.       this.firePropertyChange("label", var2, var1);
  230.       if (this.accessibleContext != null) {
  231.          this.accessibleContext.firePropertyChange("AccessibleVisibleData", var2, var1);
  232.       }
  233.  
  234.       this.invalidate();
  235.       this.repaint();
  236.    }
  237.  
  238.    public void addSeparator() {
  239.       this.add((Component)(new Separator()));
  240.    }
  241.  
  242.    public void insert(Action var1, int var2) {
  243.       JMenuItem var3 = this.createActionComponent(var1);
  244.       var3.setAction(var1);
  245.       this.insert((Component)var3, var2);
  246.    }
  247.  
  248.    public void insert(Component var1, int var2) {
  249.       if (var2 < 0) {
  250.          throw new IllegalArgumentException("index less than zero.");
  251.       } else {
  252.          int var3 = this.getComponentCount();
  253.          Vector var4 = new Vector();
  254.  
  255.          for(int var5 = var2; var5 < var3; ++var5) {
  256.             var4.addElement(this.getComponent(var2));
  257.             this.remove(var2);
  258.          }
  259.  
  260.          this.add((Component)var1);
  261.  
  262.          for(int var6 = 0; var6 < var4.size(); ++var6) {
  263.             this.add((Component)((Component)var4.elementAt(var6)));
  264.          }
  265.  
  266.       }
  267.    }
  268.  
  269.    public void addPopupMenuListener(PopupMenuListener var1) {
  270.       this.listenerList.add(PopupMenuListener.class, var1);
  271.    }
  272.  
  273.    public void removePopupMenuListener(PopupMenuListener var1) {
  274.       this.listenerList.remove(PopupMenuListener.class, var1);
  275.    }
  276.  
  277.    public PopupMenuListener[] getPopupMenuListeners() {
  278.       return (PopupMenuListener[])this.listenerList.getListeners(PopupMenuListener.class);
  279.    }
  280.  
  281.    public void addMenuKeyListener(MenuKeyListener var1) {
  282.       this.listenerList.add(MenuKeyListener.class, var1);
  283.    }
  284.  
  285.    public void removeMenuKeyListener(MenuKeyListener var1) {
  286.       this.listenerList.remove(MenuKeyListener.class, var1);
  287.    }
  288.  
  289.    public MenuKeyListener[] getMenuKeyListeners() {
  290.       return (MenuKeyListener[])this.listenerList.getListeners(MenuKeyListener.class);
  291.    }
  292.  
  293.    protected void firePopupMenuWillBecomeVisible() {
  294.       Object[] var1 = this.listenerList.getListenerList();
  295.       PopupMenuEvent var2 = null;
  296.  
  297.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  298.          if (var1[var3] == PopupMenuListener.class) {
  299.             if (var2 == null) {
  300.                var2 = new PopupMenuEvent(this);
  301.             }
  302.  
  303.             ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeVisible(var2);
  304.          }
  305.       }
  306.  
  307.    }
  308.  
  309.    protected void firePopupMenuWillBecomeInvisible() {
  310.       Object[] var1 = this.listenerList.getListenerList();
  311.       PopupMenuEvent var2 = null;
  312.  
  313.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  314.          if (var1[var3] == PopupMenuListener.class) {
  315.             if (var2 == null) {
  316.                var2 = new PopupMenuEvent(this);
  317.             }
  318.  
  319.             ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeInvisible(var2);
  320.          }
  321.       }
  322.  
  323.    }
  324.  
  325.    protected void firePopupMenuCanceled() {
  326.       Object[] var1 = this.listenerList.getListenerList();
  327.       PopupMenuEvent var2 = null;
  328.  
  329.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  330.          if (var1[var3] == PopupMenuListener.class) {
  331.             if (var2 == null) {
  332.                var2 = new PopupMenuEvent(this);
  333.             }
  334.  
  335.             ((PopupMenuListener)var1[var3 + 1]).popupMenuCanceled(var2);
  336.          }
  337.       }
  338.  
  339.    }
  340.  
  341.    boolean alwaysOnTop() {
  342.       return true;
  343.    }
  344.  
  345.    public void pack() {
  346.       if (this.popup != null) {
  347.          Dimension var1 = this.getPreferredSize();
  348.          if (var1 != null && var1.width == this.getWidth() && var1.height == this.getHeight()) {
  349.             this.validate();
  350.          } else {
  351.             this.popup = this.getPopup();
  352.          }
  353.       }
  354.  
  355.    }
  356.  
  357.    public void setVisible(boolean var1) {
  358.       if (var1 != this.isVisible()) {
  359.          if (!var1) {
  360.             Boolean var2 = (Boolean)this.getClientProperty("JPopupMenu.firePopupMenuCanceled");
  361.             if (var2 != null && var2 == Boolean.TRUE) {
  362.                this.putClientProperty("JPopupMenu.firePopupMenuCanceled", Boolean.FALSE);
  363.                this.firePopupMenuCanceled();
  364.             }
  365.  
  366.             this.getSelectionModel().clearSelection();
  367.          } else if (this.isPopupMenu()) {
  368.             if (this.getSubElements().length > 0) {
  369.                MenuElement[] var3 = new MenuElement[]{this, this.getSubElements()[0]};
  370.                MenuSelectionManager.defaultManager().setSelectedPath(var3);
  371.             } else {
  372.                MenuElement[] var4 = new MenuElement[]{this};
  373.                MenuSelectionManager.defaultManager().setSelectedPath(var4);
  374.             }
  375.          }
  376.  
  377.          if (var1) {
  378.             this.firePopupMenuWillBecomeVisible();
  379.             this.popup = this.getPopup();
  380.             this.firePropertyChange("visible", Boolean.FALSE, Boolean.TRUE);
  381.          } else if (this.popup != null) {
  382.             this.firePopupMenuWillBecomeInvisible();
  383.             this.popup.hide();
  384.             this.popup = null;
  385.             this.firePropertyChange("visible", Boolean.TRUE, Boolean.FALSE);
  386.             if (this.isPopupMenu()) {
  387.                MenuSelectionManager.defaultManager().clearSelectedPath();
  388.             }
  389.          }
  390.  
  391.       }
  392.    }
  393.  
  394.    private Popup getPopup() {
  395.       Popup var1 = this.popup;
  396.       if (var1 != null) {
  397.          var1.hide();
  398.       }
  399.  
  400.       PopupFactory var2 = PopupFactory.getSharedInstance();
  401.       if (this.isLightWeightPopupEnabled()) {
  402.          var2.setPopupType(0);
  403.       } else {
  404.          var2.setPopupType(1);
  405.       }
  406.  
  407.       Point var3 = this.adjustPopupLocationToFitScreen(this.desiredLocationX, this.desiredLocationY);
  408.       this.desiredLocationX = var3.x;
  409.       this.desiredLocationY = var3.y;
  410.       Popup var4 = this.getUI().getPopup(this, this.desiredLocationX, this.desiredLocationY);
  411.       var2.setPopupType(0);
  412.       var4.show();
  413.       return var4;
  414.    }
  415.  
  416.    public boolean isVisible() {
  417.       return this.popup != null;
  418.    }
  419.  
  420.    public void setLocation(int var1, int var2) {
  421.       int var3 = this.desiredLocationX;
  422.       int var4 = this.desiredLocationY;
  423.       this.desiredLocationX = var1;
  424.       this.desiredLocationY = var2;
  425.       if (this.popup != null && (var1 != var3 || var2 != var4)) {
  426.          this.popup = this.getPopup();
  427.       }
  428.  
  429.    }
  430.  
  431.    private boolean isPopupMenu() {
  432.       return !(this.invoker instanceof JMenu);
  433.    }
  434.  
  435.    public Component getInvoker() {
  436.       return this.invoker;
  437.    }
  438.  
  439.    public void setInvoker(Component var1) {
  440.       Component var2 = this.invoker;
  441.       this.invoker = var1;
  442.       if (var2 != this.invoker && this.ui != null) {
  443.          this.ui.uninstallUI(this);
  444.          this.ui.installUI(this);
  445.       }
  446.  
  447.       this.invalidate();
  448.    }
  449.  
  450.    public void show(Component var1, int var2, int var3) {
  451.       this.setInvoker(var1);
  452.       Frame var4 = getFrame(var1);
  453.       if (var4 != this.frame && var4 != null) {
  454.          this.frame = var4;
  455.          if (this.popup != null) {
  456.             this.setVisible(false);
  457.          }
  458.       }
  459.  
  460.       if (var1 != null) {
  461.          Point var5 = var1.getLocationOnScreen();
  462.          long var6 = (long)var5.x + (long)var2;
  463.          long var8 = (long)var5.y + (long)var3;
  464.          if (var6 > 2147483647L) {
  465.             var6 = 2147483647L;
  466.          }
  467.  
  468.          if (var6 < -2147483648L) {
  469.             var6 = -2147483648L;
  470.          }
  471.  
  472.          if (var8 > 2147483647L) {
  473.             var8 = 2147483647L;
  474.          }
  475.  
  476.          if (var8 < -2147483648L) {
  477.             var8 = -2147483648L;
  478.          }
  479.  
  480.          this.setLocation((int)var6, (int)var8);
  481.       } else {
  482.          this.setLocation(var2, var3);
  483.       }
  484.  
  485.       this.setVisible(true);
  486.    }
  487.  
  488.    JPopupMenu getRootPopupMenu() {
  489.       JPopupMenu var1;
  490.       for(var1 = this; var1 != null && !var1.isPopupMenu() && var1.getInvoker() != null && var1.getInvoker().getParent() != null && var1.getInvoker().getParent() instanceof JPopupMenu; var1 = (JPopupMenu)var1.getInvoker().getParent()) {
  491.       }
  492.  
  493.       return var1;
  494.    }
  495.  
  496.    /** @deprecated */
  497.    @Deprecated
  498.    public Component getComponentAtIndex(int var1) {
  499.       return this.getComponent(var1);
  500.    }
  501.  
  502.    public int getComponentIndex(Component var1) {
  503.       int var2 = this.getComponentCount();
  504.       Component[] var3 = this.getComponents();
  505.  
  506.       for(int var4 = 0; var4 < var2; ++var4) {
  507.          Component var5 = var3[var4];
  508.          if (var5 == var1) {
  509.             return var4;
  510.          }
  511.       }
  512.  
  513.       return -1;
  514.    }
  515.  
  516.    public void setPopupSize(Dimension var1) {
  517.       Dimension var2 = this.getPreferredSize();
  518.       this.setPreferredSize(var1);
  519.       if (this.popup != null) {
  520.          Dimension var3 = this.getPreferredSize();
  521.          if (!var2.equals(var3)) {
  522.             this.popup = this.getPopup();
  523.          }
  524.       }
  525.  
  526.    }
  527.  
  528.    public void setPopupSize(int var1, int var2) {
  529.       this.setPopupSize(new Dimension(var1, var2));
  530.    }
  531.  
  532.    public void setSelected(Component var1) {
  533.       SingleSelectionModel var2 = this.getSelectionModel();
  534.       int var3 = this.getComponentIndex(var1);
  535.       var2.setSelectedIndex(var3);
  536.    }
  537.  
  538.    public boolean isBorderPainted() {
  539.       return this.paintBorder;
  540.    }
  541.  
  542.    public void setBorderPainted(boolean var1) {
  543.       this.paintBorder = var1;
  544.       this.repaint();
  545.    }
  546.  
  547.    protected void paintBorder(Graphics var1) {
  548.       if (this.isBorderPainted()) {
  549.          super.paintBorder(var1);
  550.       }
  551.  
  552.    }
  553.  
  554.    public Insets getMargin() {
  555.       return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
  556.    }
  557.  
  558.    boolean isSubPopupMenu(JPopupMenu var1) {
  559.       int var2 = this.getComponentCount();
  560.       Component[] var3 = this.getComponents();
  561.  
  562.       for(int var4 = 0; var4 < var2; ++var4) {
  563.          Component var5 = var3[var4];
  564.          if (var5 instanceof JMenu) {
  565.             JMenu var6 = (JMenu)var5;
  566.             JPopupMenu var7 = var6.getPopupMenu();
  567.             if (var7 == var1) {
  568.                return true;
  569.             }
  570.  
  571.             if (var7.isSubPopupMenu(var1)) {
  572.                return true;
  573.             }
  574.          }
  575.       }
  576.  
  577.       return false;
  578.    }
  579.  
  580.    private static Frame getFrame(Component var0) {
  581.       Object var1;
  582.       for(var1 = var0; !(var1 instanceof Frame) && var1 != null; var1 = ((Component)var1).getParent()) {
  583.       }
  584.  
  585.       return (Frame)var1;
  586.    }
  587.  
  588.    protected String paramString() {
  589.       String var1 = this.label != null ? this.label : "";
  590.       String var2 = this.paintBorder ? "true" : "false";
  591.       String var3 = this.margin != null ? this.margin.toString() : "";
  592.       String var4 = this.isLightWeightPopupEnabled() ? "true" : "false";
  593.       return super.paramString() + ",desiredLocationX=" + this.desiredLocationX + ",desiredLocationY=" + this.desiredLocationY + ",label=" + var1 + ",lightWeightPopupEnabled=" + var4 + ",margin=" + var3 + ",paintBorder=" + var2;
  594.    }
  595.  
  596.    public AccessibleContext getAccessibleContext() {
  597.       if (this.accessibleContext == null) {
  598.          this.accessibleContext = new AccessibleJPopupMenu(this);
  599.       }
  600.  
  601.       return this.accessibleContext;
  602.    }
  603.  
  604.    private void writeObject(ObjectOutputStream var1) throws IOException {
  605.       Vector var2 = new Vector();
  606.       var1.defaultWriteObject();
  607.       if (this.invoker != null && this.invoker instanceof Serializable) {
  608.          var2.addElement("invoker");
  609.          var2.addElement(this.invoker);
  610.       }
  611.  
  612.       if (this.popup != null && this.popup instanceof Serializable) {
  613.          var2.addElement("popup");
  614.          var2.addElement(this.popup);
  615.       }
  616.  
  617.       var1.writeObject(var2);
  618.       if (this.getUIClassID().equals("PopupMenuUI")) {
  619.          byte var3 = JComponent.getWriteObjCounter(this);
  620.          --var3;
  621.          JComponent.setWriteObjCounter(this, var3);
  622.          if (var3 == 0 && this.ui != null) {
  623.             this.ui.installUI(this);
  624.          }
  625.       }
  626.  
  627.    }
  628.  
  629.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  630.       var1.defaultReadObject();
  631.       Vector var2 = (Vector)var1.readObject();
  632.       int var3 = 0;
  633.       int var4 = var2.size();
  634.       if (var3 < var4 && var2.elementAt(var3).equals("invoker")) {
  635.          ++var3;
  636.          this.invoker = (Component)var2.elementAt(var3);
  637.          ++var3;
  638.       }
  639.  
  640.       if (var3 < var4 && var2.elementAt(var3).equals("popup")) {
  641.          ++var3;
  642.          this.popup = (Popup)var2.elementAt(var3);
  643.          ++var3;
  644.       }
  645.  
  646.    }
  647.  
  648.    public void processMouseEvent(MouseEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
  649.    }
  650.  
  651.    public void processKeyEvent(KeyEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
  652.       MenuKeyEvent var4 = new MenuKeyEvent(var1.getComponent(), var1.getID(), var1.getWhen(), var1.getModifiers(), var1.getKeyCode(), var1.getKeyChar(), var2, var3);
  653.       this.processMenuKeyEvent(var4);
  654.       if (var4.isConsumed()) {
  655.          var1.consume();
  656.       }
  657.  
  658.    }
  659.  
  660.    private void processMenuKeyEvent(MenuKeyEvent var1) {
  661.       switch (var1.getID()) {
  662.          case 400:
  663.             this.fireMenuKeyTyped(var1);
  664.             break;
  665.          case 401:
  666.             this.fireMenuKeyPressed(var1);
  667.             break;
  668.          case 402:
  669.             this.fireMenuKeyReleased(var1);
  670.       }
  671.  
  672.    }
  673.  
  674.    private void fireMenuKeyPressed(MenuKeyEvent var1) {
  675.       Object[] var2 = this.listenerList.getListenerList();
  676.  
  677.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  678.          if (var2[var3] == MenuKeyListener.class) {
  679.             ((MenuKeyListener)var2[var3 + 1]).menuKeyPressed(var1);
  680.          }
  681.       }
  682.  
  683.    }
  684.  
  685.    private void fireMenuKeyReleased(MenuKeyEvent var1) {
  686.       Object[] var2 = this.listenerList.getListenerList();
  687.  
  688.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  689.          if (var2[var3] == MenuKeyListener.class) {
  690.             ((MenuKeyListener)var2[var3 + 1]).menuKeyReleased(var1);
  691.          }
  692.       }
  693.  
  694.    }
  695.  
  696.    private void fireMenuKeyTyped(MenuKeyEvent var1) {
  697.       Object[] var2 = this.listenerList.getListenerList();
  698.  
  699.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  700.          if (var2[var3] == MenuKeyListener.class) {
  701.             ((MenuKeyListener)var2[var3 + 1]).menuKeyTyped(var1);
  702.          }
  703.       }
  704.  
  705.    }
  706.  
  707.    public void menuSelectionChanged(boolean var1) {
  708.       if (this.invoker instanceof JMenu) {
  709.          JMenu var2 = (JMenu)this.invoker;
  710.          if (var1) {
  711.             var2.setPopupMenuVisible(true);
  712.          } else {
  713.             var2.setPopupMenuVisible(false);
  714.          }
  715.       }
  716.  
  717.       if (this.isPopupMenu() && !var1) {
  718.          this.setVisible(false);
  719.       }
  720.  
  721.    }
  722.  
  723.    public MenuElement[] getSubElements() {
  724.       Vector var2 = new Vector();
  725.       int var3 = this.getComponentCount();
  726.  
  727.       for(int var4 = 0; var4 < var3; ++var4) {
  728.          Component var5 = this.getComponent(var4);
  729.          if (var5 instanceof MenuElement) {
  730.             var2.addElement(var5);
  731.          }
  732.       }
  733.  
  734.       MenuElement[] var1 = new MenuElement[var2.size()];
  735.       int var7 = 0;
  736.  
  737.       for(int var6 = var2.size(); var7 < var6; ++var7) {
  738.          var1[var7] = (MenuElement)var2.elementAt(var7);
  739.       }
  740.  
  741.       return var1;
  742.    }
  743.  
  744.    public Component getComponent() {
  745.       return this;
  746.    }
  747.  
  748.    public boolean isPopupTrigger(MouseEvent var1) {
  749.       return this.getUI().isPopupTrigger(var1);
  750.    }
  751.  
  752.    static {
  753.       popupPostionFixDisabled = ((String)AccessController.doPrivileged(new GetPropertyAction("javax.swing.adjustPopupLocationToFit", ""))).equals("false");
  754.       classLock = new Object();
  755.    }
  756. }
  757.